﻿using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace BaseControlLibrary
{
    [ValueConversion(typeof(string), typeof(BitmapImage))]
    public class ImageConverter:IValueConverter
    {

        #region IValueConverter 成员

        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return null;
            string imageUrl = value.ToString();
            if (string.IsNullOrEmpty(imageUrl))
                return null;
            return CommonConvert.GetImageSource(imageUrl);
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new System.NotImplementedException();
        }

        #endregion
    }
}
